import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Properties;
import java.util.Scanner;

/**
 * @author VernHe
 * @date 2021年07月27日 20:03
 */
public class Temp_01 {
    public static void main(String[] args) {
        getNum();
    }

    private static void getNum() {
        Scanner input = new Scanner(System.in);
        Integer len = Integer.valueOf(input.next());
        System.out.println(len);
        Integer k = Integer.valueOf(input.next());
        System.out.println(k);
        input.nextLine();
        String arr_str = input.nextLine();
        String[] arr = arr_str.split(" ");

        // 保存每个节点出现的次数
        HashMap<String,Node> hashMap = new HashMap();
        Node result = null;
        for (int i = 0; i < len; i++) {
            // map中是不存在
            if (!hashMap.containsKey(arr[i])) {
                hashMap.put(arr[i],new Node(arr[i],i));
            } else {
                // 存在就让count++
                Node node = hashMap.get(arr[i]);
                int newCount = ++node.count;
                node.setCount(newCount);
                if (newCount > k) {
                    // 满足条件就保存
                    if (result == null || node.index < result.index) {
                        result = node;
                    }
                }
            }
        }

        System.out.println(result == null ? -1 : Integer.valueOf(result.val));
    }

    private static class Node implements Comparable{
        // 值
        private String val;
        // 下标
        private int index;
        // 出现次数
        private int count = 1;

        public Node(String val, int index) {
            this.val = val;
            this.index = index;
        }

        @Override
        public int compareTo(Object o) {
            Node node = (Node)o;
            // 根据下标排序
            return ((Node) o).index - this.index;
        }

        public void setCount(int count) {
            this.count = count;
        }
    }
}
